<!DOCTYPE html>
<html>
<head>
    <title>短链接</title>
    <meta name="keywords" content="{$site_info.site_seo_keywords|default=''}"/>
    <meta name="description" content="{$site_info.site_seo_description|default=''}">
    <include file="public@head"/>
    <style>
        #article_content img {
            height: auto !important;
            max-width: 100%;
        }
        .compact_text {
            min-height:240px;
        }
    </style>

</head>
<body class="body-white">
<include file="public@nav"/>
<div class="container tc-main">
    <div class="row">
        <div class="col-md-9">
                <div class="panel-group" id="accordion2">
                    <form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:cmf_plugin_url('Tools://tinyurls/rollbackPost')}" >
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <a class="accordion-toggle" data-toggle="collapse2" data-parent="#accordion2">
                                <i class="fa fa-plus"></i>
                                <!--<i class="fa fa-minus"></i>
                                -->短链接批量转化工具 【复制文本】                          
                            </a>
                        </div>
                        <div id="collapse475" class="panel-body">
                            <div class="form-group">
                                <div class="col-sm-12">
                                    <textarea class="form-control compact_text" id="compact_urls" name="compact_urls" placeholder='原始文本粘贴到这里，如短链接多次压缩，仅支持一次跳转'></textarea>
                                </div>
                            </div>
                           
                            <div class="download-btns">                        
                                <button class="btn btn-warning pull-left js-ajax-submit" type='submit' target="_blank" data-success='rollbackSuccess' >一键还原</button>
                                <a href="#" class="btn btn-success pull-left" id='clearBtn' >清空</a>
                            </div>
                            
                            <div class="clearfix"></div>
                            <br/>
                            <div class="form-group">
                                <div class="col-sm-12">
                                    <textarea class="form-control compact_text" id="converted_urls" name="converted_urls" disabled='disabled' placeholder='转换后的内容'></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                    </form>
                </div>

        </div>
        <div class="col-md-3">
            <php>            
            $portal_tags = think\Db::name('portal_tag')
                ->where(['status' => '1'])
                ->select();
            </php>
            <div class="tc-box">
                <div class="headtitle">
                    <h2>时间标签</h2>
                </div>
                <div class="tag-cloud">
                    <volist name="portal_tags" id="vo">
                        <a href="{:cmf_url('portal/tag/index',array('id'=>$vo['id']))}" class="tag-item" target="_blank">{$vo.name}</a>
                    </volist>			
                </div>
            </div>

            <div class="tc-box">
                <div class="headtitle">
                    <h2>最新发布</h2>
                </div>
                <div class="ranking">
                    <php>
                        $hot_articles=[];
                    </php>
                    <ul class="list-unstyled">
                        <portal:articles item="vo" limit="5" order="post.post_hits DESC"
                                            categoryIds="1">
                            <php>$top=$key<3?"top3":"";</php>
                            <li class="{$top}">
                                <i>{$key+1}</i>
                                <a title="{$vo.post_title}"
                                    href="{:cmf_url('portal/Article/index',array('id'=>$vo['id']))}">
                                    {$vo.post_title}
                                </a>
                            </li>
                        </portal:articles>
                    </ul>
                </div>
            </div>
            
            
            <div class="tc-box">
                <div class="headtitle">
                    <h2>热门文章</h2>
                </div>
                <div class="posts">
                    <portal:articles item="vo" limit="5" order="post.published_time DESC"
                                        categoryIds="1">
                        <dl class="dl-horizontal">
                            <dt>
                                <a class="img-wraper"
                                    href="{:cmf_url('portal/Article/index',array('id'=>$vo.id))}">
                                    <if condition="empty($vo.more.thumbnail)">
                                        <img src="__PLUGIN_TMPL__/public/assets/images/default_tupian4.png"
                                                class="img-responsive" alt="{$vo.post_title}"/>
                                        <else/>
                                        <img src="{:cmf_get_image_url($vo.more.thumbnail)}"
                                                class="img-responsive" alt="{$vo.post_title}"/>
                                    </if>
                                </a>
                            </dt>
                            <dd>
                                <a href="{:cmf_url('portal/Article/index',array('id'=>$vo['id']))}">{$vo.post_title}</a>
                            </dd>
                        </dl>
                    </portal:articles>
                </div>
            </div>
            

        </div>
    </div>

    <include file="public@footer"/>
</div>

<script src="__STATIC__/js/admin.js"></script>
<include file="public@scripts"/>
<script>
    function rollbackSuccess(res, statusText, xhr, $form) {
        var res = res;
        noty({
            text: '操作成功',
            type: 'success',
            layout: 'topCenter',
            modal: true,
            // animation: {
            //     open: 'animated bounceInDown', // Animate.css class names
            //     close: 'animated bounceOutUp', // Animate.css class names
            // },
            timeout: 600,
            callback: {
                afterClose: function() {
                    //console.log(this.text);
                    if(res.code == 1) {
                        $('#converted_urls').val(res.data.compact_urls);
                    }
                } 
            }
        }).show();
        /*
        console.log(res.code);
        */
    }
    $('#clearBtn').click(function(){
       $('#compact_urls').val(''); 
       $('#converted_urls').val(''); 
    });
</script>

</body>
</html>